<template>
  <div class="components-head-bar">
    <!-- 左边 -->
    <div class="head-left">
      <p class="line" />
      <span class="text">{{ title }}</span>
    </div>
    <!-- 右边 -->
    <div class="head-right">
      <DateTypeSelect
        :date-options="dateOptions"
        :date-type="dateType"
        @date-change="onDateChange"
      />
      <slot>
        <el-button
          v-if="showExport"
          type="primary"
          @click="onExport"
        >
          {{ $t('order.export') }}
        </el-button>
      </slot>
    </div>
  </div>
</template>

<script setup>
import DateTypeSelect from '../../components/date-type-select.vue'

// eslint-disable-next-line no-unused-vars
const props = defineProps({
  title: {
    type: String,
    default: '标题'
  },
  showExport: {
    type: Boolean,
    default: false
  },
  dateOptions: {
    type: Array,
    default: () => {
      return []
    }
  },
  dateType: {
    type: Number,
    default: 5
  }
})

const emit = defineEmits(['dateChange', 'export'])
const onDateChange = (data) => {
  emit('dateChange', data)
}

const onExport = () => {
  emit('export')
}

</script>

<style lang="scss" scoped>
.components-head-bar  {
  width: 100%;
  height: 62px;
  background: #F7F8FA;
  box-sizing: border-box;
  padding: 19px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  .head-left {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    .line{
      width: 4px;
      height: 19px;
      background: #155BD4;
      opacity: 1;
      border-radius: 2px;
      margin-right: 10px;
    }
    .text{
      font-size: 18px;
      font-weight: bold;
      color: #333333;
      opacity: 1;
    }
  }
  .head-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
  }
}
</style>
